package com.example.demo.news.service;


import com.example.demo.navigation.bean.NavBean;
import com.example.demo.news.bean.NewsBean;
import com.example.demo.news.bean.NewsType;
import com.example.demo.news.repository.NewsRepository;
import com.example.demo.service.BaseService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class NewsService extends BaseService<NewsBean,NewsRepository>{




    @Override
    public NewsBean save(NewsBean newsBean) {
        newsBean.setTime(LocalDateTime.now());
        return super.save(newsBean);

    }

    public Page<NewsBean> getNewsByType(PageRequest pageRequest, NewsType newsType){
        return repository.findAllByNewsType(pageRequest,newsType);
    }
}
